<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
</head>
<body>
<input type="text" name="">

<script type="text/javascript">
	let inp = document.querySelector('input')

	//用户按下的时候触发
	// inp.onkeydown = function() {
	// 	console.log(this.value)
	// }

	//用户释放的时候触发
	inp.onkeyup = function() {
		console.log(this.value)
	}

	//禁用f12
	document.onkeydown = function(e) {
		//键盘码
		console.log(e.keyCode)
		if(e.keyCode == 123){
			e.preventDefault()
			alert('打不开')
		}
	}

</script>
</body>
</html>